import { CCBoolean, Vec3 } from "cc";
import { v3 } from "cc";
import { _decorator } from "cc";
import NSyncStateServer, { NPrefab } from "../../../ngame/sync/state/NSyncStateServer";
import NSyncDelete from "../../../ngame/sync/state/tools/NSyncDelete";
import { uuid2 } from "../../../ngame/util/util-ngame";
import GameConst, { NPrefabConst, NPrefabKeys } from "../../GameConst";
import NSyncServer from "../../ngame/sync/NSyncServer";
import NWorld2Component from "../../ngame/sync/NWorld2Component";
const { ccclass, property,executeInEditMode,uniquelyReferenced } = _decorator;

declare const CC_EDITOR;

@ccclass('ITreeController')
export class ITreeController extends NWorld2Component{

    onLoad(){
        super.onLoad();
        
        //监听删除
        this.addSync(new NSyncDelete(this));
    }

    initData(data:Vec3){
        this.node.worldPosition = Object.assign(v3(),data)
    }


    //砍树
    hewedTree(){
        console.log("砍树");
        this.delete();
        //在原来的位置生成木材
        NSyncServer.getIns().addNode(NPrefabKeys.木材,this.node.position.clone());
    }

}

